package utils

import (
	"fmt"
	"github.com/smartwalle/alipay/v3"
)

var err error

func Alipay(OutTradeNo string, TotalAmount string) string {
	appId := "9021000150603294"
	var privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCWijv3EEocNLuCWNBc3yhINqE8XhWf5tputyj9EUJ5TYMbveBO39XliiXg8YoF7fV8w/bB+oKmC4/YHYId08A7kbit1goJG8DXdKiesvFIuTkrVB/7nqTs1AaaDJQdX7YdZiU0M1Bqfgfz1GCcXQjyBwV+DR0tZTuUzRK4/a+8jy9oDuHf+OfQztlpDxLZ8f2oOJNAxj5EcuiNGn9L9EH8zdnb1hgMnU2f3N0C/z26TMKhZtRAtGnzFBKMCzTJJLk4XWO7FSzPeyVjMKiEHE9KALb4mG4yoB5RY3i/+ey1qjI2aNuWxcJyX7XlFy21v8SjKzXspUzPZ8h0qY1yLVKHAgMBAAECggEAadXXoLQAFmJwbYx5OMHfNR3LL4DJ3ThU2z/D/l8zB8sZ4NgWKf2uCImeZc4Khm6sh0HSar/vOEOqpnrgbo3feUHSv8xaE9tCMXef0KrnfYRTEAY90g3Pz3ylA4rSWvBePb8Bavikkan3d1IZdfTmhBmxn9Qibjbcs5mVjx8zfPFqjjiwLyFzJFD6PhvFD+dYVol41UllXueUiZDwloO5sMMDlr034OtJ20M50+8783K7IbypLjfDRrJzzHJcmYEZLBSGA5wPLMevnvmNs3q1rvxhLoWVaBF8Ru/Pvq6Jw3PWFAWXHCVJ7irttjY5c9b5KDUqSx/fRh67OIB9BVckcQKBgQDjfZL/yf2NTTKn0hNi9sT1SUQKx7qChX9Vqu7KMrkq6cCCVQLCHG203u46oryslCk2idyCdtxTfNFZgi29z++dL267cmFP9/YBJMYchVYa2rT7koZxygrhL7CgeUCZvY0BlzzfKfl2IqHU0C3iI6wzZTqXpEdJvq7pfOQb800a3wKBgQCpZ+hDzv+XZlhd2BcT9hCIqGAWT9Fflvx9K1CduhGZ5aNBl6JMliF60GIldL1b1XcXixqf3qyodtFYvWDNC27vKvzWDg0mvVtePxZn/E4V2B+e6a+TYHi5APvD/8UsQ9oslU5RGjFCNTY7WhBI3UmsWXUw5aC4+VeAwZ9gDNtlWQKBgFBo6ZXKUvooKFiTc9DOQu4kmI1q7a0G/OxOABuudC8L8sTewZvVKp39Ep3dOe2SbULe1fezhcto2iLWVc66+gpIYs6U7nqyvdzHn9Mi+j2BwukNcMI11USlc7w1P7VX/8hpKdYD4y5zrVoov58oVszP4jcJlT0mznKvd329sSpnAoGAcC0rI0O+Af42g6Xk2kX1etisD/o4taigdy4oitk8cIEckwGa6kX703yLkSv1fAslekSVk8l64W8Uf0OgBwcMJXl8xS22zbFUAFucNa1f850Si0NJDTkzl6YsEQScBwzDOwR/QLssZSAhUjn4UJegAm2WaZOU0wfhRpRwOcUpvrkCgYAZkWu1Bp8CCg9rqcS0fxoZv3iVdkKvCmYu0l2XciBZpAObFA1BhkMIE/QeeS8zqzitaFcN5GEBVR921jKjGRIgU+56QeqfFE/sl3Eg/kb0tHIGjKcl3RWWxJwKGbGKIa1D0UFBTkUmV/+LrJLnupWelwh+UguWUOBrMqqRt161uA==" // 必须，上一步中使用 RSA签名验签工具 生成的私钥
	var client, err = alipay.New(appId, privateKey, false)
	if err != nil {
		fmt.Println(err)
		return ""
	}
	var p = alipay.TradeWapPay{}
	p.NotifyURL = "http://xxx"
	p.ReturnURL = "http://baidu.com"
	p.Subject = "医院预约订单"
	p.OutTradeNo = OutTradeNo
	p.TotalAmount = TotalAmount
	p.ProductCode = "QUICK_WAP_WAY"
	url, err := client.TradeWapPay(p)
	if err != nil {
		fmt.Println(err)
	}
	// 这个 payURL 即是用于打开支付宝支付页面的 URL，可将输出的内容复制，到浏览器中访问该 URL 即可打开支付页面。
	var payURL = url.String()
	fmt.Println(payURL)
	return ""
}
